Passed
Push — develop ( db4836...f63737 )
by Elvis Henrique
02:35
created

webpack.development.js ➔ ???   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 1
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
dl 0
loc 1
rs 10
c 0
b 0
f 0
nop 1
1
/**
2
 * The external dependencies.
3
 */
4
const { ProvidePlugin, WatchIgnorePlugin } = require('webpack');
5
const CleanWebpackPlugin = require('clean-webpack-plugin');
6
const ExtractTextPlugin = require('extract-text-webpack-plugin');
7
const ManifestPlugin = require('webpack-manifest-plugin');
8
9
/**
10
 * The internal dependencies.
11
 */
12
const utils = require('./lib/utils');
13
const configLoader = require('./config-loader');
14
const spriteSmith = require('./spritesmith');
15
const postcss = require('./postcss');
16
const browsersync = require('./browsersync');
17
18
/**
19
 * Setup the env.
20
 */
21
const { env: envName } = utils.detectEnv();
22
23
/**
24
 * Setup babel loader.
25
 */
26
const babelLoader = {
27
  loader: 'babel-loader',
28
  options: {
29
    cacheDirectory: true,
30
    comments: false,
31
    presets: [
32
      [
33
        'env',
34
        {
35
          targets: {
36
            browsers: ['last 3 versions'],
37
          },
38
        },
39
      ],
40
      // airbnb not included as stage-2 already covers it
41
      'stage-2',
42
    ],
43
  },
44
};
45
46
/**
47
 * Setup extract text plugin.
48
 */
49
const extractSass = new ExtractTextPlugin({
50
  filename: 'styles/[name].css',
51
});
52
53
/**
54
 * Setup webpack plugins.
55
 */
56
const plugins = [
57
  new CleanWebpackPlugin(utils.distPath(), {
58
    root: utils.themeRootPath(),
59
  }),
60
  new WatchIgnorePlugin([
61
    utils.distImagesPath('sprite.png'),
62
    utils.distImagesPath('[email protected]'),
63
  ]),
64
  new ProvidePlugin({
65
    $: 'jquery',
66
    jQuery: 'jquery',
67
  }),
68
  extractSass,
69
  spriteSmith,
70
  browsersync,
71
  new ManifestPlugin(),
72
];
73
74
/**
75
 * Export the configuration.
76
 */
77
module.exports = {
78
  /**
79
   * The input.
80
   */
81
  entry: require('./webpack/entry'),
82
83
  /**
84
   * The output.
85
   */
86
  output: require('./webpack/output'),
87
88
  /**
89
   * Resolve utilities.
90
   */
91
  resolve: require('./webpack/resolve'),
92
93
  /**
94
   * Resolve the dependencies that are available in the global scope.
95
   */
96
  externals: require('./webpack/externals'),
97
98
  /**
99
   * Setup the transformations.
100
   */
101
  module: {
102
    rules: [
103
      /**
104
       * Add support for blogs in import statements.
105
       */
106
      {
107
        enforce: 'pre',
108
        test: /\.(js|jsx|css|scss)$/,
109
        use: 'import-glob',
110
      },
111
112
      /**
113
       * Handle the theme config.json.
114
       */
115
      {
116
        test: utils.themeRootPath('config.json'),
117
        use: configLoader,
118
      },
119
120
      /**
121
       * Handle scripts.
122
       */
123
      {
124
        test: utils.tests.scripts,
125
        exclude: /node_modules/,
126
        use: babelLoader,
127
      },
128
129
      /**
130
       * Handle styles.
131
       */
132
      {
133
        test: utils.tests.styles,
134
        use: extractSass.extract({
135
          publicPath: '../',
136
          use: [
137
            {
138
              loader: 'css-loader',
139
              options: {
140
                minimize: false,
141
              },
142
            },
143
            {
144
              loader: 'postcss-loader',
145
              options: postcss,
146
            },
147
            'sass-loader',
148
          ],
149
        }),
150
      },
151
152
      /**
153
       * Handle images.
154
       */
155
      {
156
        test: utils.tests.images,
157
        use: [
158
          {
159
            loader: 'file-loader',
160
            options: {
161
              name: file => `images/[name].${utils.filehash(file).substr(0, 10)}.[ext]`,
162
            },
163
          },
164
        ],
165
      },
166
167
      /**
168
       * Handle fonts.
169
       */
170
      {
171
        test: utils.tests.fonts,
172
        use: [
173
          {
174
            loader: 'file-loader',
175
            options: {
176
              name: file => `fonts/[name].${utils.filehash(file).substr(0, 10)}.[ext]`,
177
            },
178
          },
179
        ],
180
      },
181
    ],
182
  },
183
184
  /**
185
   * Setup the transformations.
186
   */
187
  plugins,
188
189
  /**
190
   * Setup the development tools.
191
   */
192
  mode: envName,
0 ignored issues
show
Bug introduced by
The variable envName seems to be never declared. If this is a global, consider adding a /** global: envName */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
193
  cache: true,
194
  bail: false,
195
  watch: true,
196
  devtool: 'source-map',
197
};
198